<?php
//system/core/core.class.php
class Core{
    public static function  run(){
 //      echo "run()";
        self::init();
        self::autoload();
        self::dispatch();
    }
   //初始化方法 
    private static function init(){
    //@param define
    //@param DIRECTORY_SEPARATOR->/
    define("DS", DIRECTORY_SEPARATOR);//定义分隔符
    define('ROOT', getcwd() . DS);//定义当前工作目录
    define('APP_PATH', ROOT . 'app' . DS);//定义web根目录
    define('SYSTEM_PATH', ROOT . 'sysytem' . DS);//定义核心文件目录
    define('PUBLIC_PATH', ROOT . 'public'.DS);//定义静态资源目录
    //定义web目录
    define('CONFIG_PATH', APP_PATH . 'config' .DS);
    define('CONTROLLER_PATH',APP_PATH .'controller'.DS);
    define('MODEL_PATH',APP_PATH . 'model' . DS);
    define('VIEW_PATH',APP_PATH . 'view' .DS);
    //定义框架目录
    define('CORE_PATH',SYSTEM_PATH . 'core' .DS);
    define('DB_PATH', SYSTEM_PATH .'db'.DS);
    define('LIB_PATH',SYSTEM_PATH .'lib'.DS);
    define('HELPER_PATH', SYSTEM_PATH .'helpers'.DS);
    define('UPLAOD', PUBLIC_PATH .'upload'. DS);
    //index.php?p=admin&c=Goods&a=add
    define('PLATFORM', isset($_REQUEST['q'])?$_REQUEST['q']:'home');
    define('CONTROLLER', isset($_REQUEST['c'])?$_REQUEST['c']:'Index');
    define('ACTION', isset($_REQUEST['a'])?$_REQUEST['a']:'index');
    
    define('CURR_CONTROLLER_PATH', CONTROLLER_PATH . PLATFORM .DS);
    define('CURR_VIEW_PATH',VIEW_PATH .PLATFORM . DS );
    
    //加载核心类
    require CORE_PATH .'Controller.class.php';
    require CORE_PATH .'Loader.class.php';
    require DB_PAHT .'Mysql.class.php';
    require CORE_PATH .'Model.class.php';
    //加载配置文件
    $GLOBALS['config'] = include CONFIG_PATH . 'config.php';
    //开启session
    session_start();
    }
    //自动加载
    private static function autoload(){
        spl_autoload_register(array(__CLASS__,'load'));
    }
    private static function load($classname){
        
    }
    private static function dispatch(){
        
    }
}

